/*
 * Copyright (c)  2015~2020, xforceplus
 * All rights reserved.
 * Project:datacare-orm
 * Id: RowMapperContext.java   2020-09-29 23-37-57
 * Author: Evan
 */
package cn.datacare.orm.damoin;

import cn.datacare.orm.manager.impl.SQLManager;
import cn.datacare.orm.source.SQLScript;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: 2015~2020
 * </p>
 * <p>
 * Company/Department: xforceplus
 * </p>
 *
 * @author Evan
 * <b>Creation Time:</b> 2020-09-29 23-37-57
 * @since V1.0
 */
public class RowMapperContext {
    SQLManager sm;
    SQLScript script;
    Map<Class<?>, Map<Object,Object>> cache = new HashMap<>();

    public SQLManager getSQLManager() {
        return sm;
    }

    public SQLScript getSQLScript() {
        return script;
    }

    public Object getCache(Class<?> c,Object key) {
        Map<Object,Object> map = cache.get(c);
        if(map==null){
            return null;
        }
        Object value = map.get(key);
        return value ;
    }
    public void setCache(Class<?> c,Object key,Object value) {
        Map<Object,Object> map = cache.get(c);
        if(map==null){
            map = Collections.emptyMap();
            cache.put(c, map);
        }
        map.put(key, value);

    }
}
